"""
系统相关模型
"""
from datetime import datetime
from sqlalchemy import Column, Integer, String, Text, DateTime, BigInteger
from app.db.session import Base


class SiteSetting(Base):
    """网站配置表"""
    __tablename__ = "site_settings"
    
    id = Column(Integer, primary_key=True, index=True, comment="主键ID")
    key_name = Column(String(100), unique=True, nullable=False, index=True, comment="配置键")
    value = Column(Text, comment="配置值")
    description = Column(String(255), comment="描述")
    group_name = Column(String(50), comment="分组")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")
    updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")


class VisitLog(Base):
    """访问日志表"""
    __tablename__ = "visit_logs"
    
    id = Column(BigInteger, primary_key=True, index=True, comment="主键ID")
    page_url = Column(String(255), index=True, comment="页面URL")
    page_title = Column(String(100), comment="页面标题")
    ip_address = Column(String(50), comment="IP地址")
    user_agent = Column(Text, comment="浏览器UA")
    referer = Column(String(255), comment="来源")
    visit_time = Column(DateTime, default=datetime.now, index=True, comment="访问时间")

